package com.example.mq2.demo;

import com.example.mq2.mqclient.Channel;
import com.example.mq2.mqclient.Connection;
import com.example.mq2.mqclient.ConnectionFactory;
import com.example.mq2.mqserver.core.ExchangeType;

import java.io.IOException;

public class Producer {

    public static void main(String[] args) throws IOException {
        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setHost("127.0.0.1");
        connectionFactory.setPort(9090);
        Connection connection = connectionFactory.createConnection();
        Channel channel = connection.createChannel();

//        //初始准备工作
//        channel.exchangeDeclare("testExchange", ExchangeType.Direct, true, false,
//                null);
//        channel.queueDeclare("testQueue", true, false, false, null);
//        channel.queueBind("testExchange", "testQueue", "testBindKey");
        //投放消息
        channel.basicPublish("testExchange", "testQueue", null, "hello".getBytes());

        channel.close();
        connection.close();
    }

}
